<template>
  <div class="content-div">
    <div class="banner-box">
      <div class="banner-bg"></div>
      <rw-calendar @getCheckDate="getCheckDate" :rwDateArr="rwDateArr" v-if="rwDateArr&&flag"></rw-calendar>
    </div>
    <div class="list-outbox">
      <div class="list-box">
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
          <div>
            <div @click="toPage('/order-detail-waiter', {order_goods_id: item.order_goods_id})" class="list-item-box1" v-for="(item, index) in list" :key="index">
              <div class="list-head-box">
                <div class="list-name-box">
                  <span class="list-name" style="float:left;">{{item.give_service_name}}</span>
                  <span class="list-type" style="float:right;">{{item.hospital_name}}</span>
                </div>
                <div class="list-content-box">
                  <span>{{item.visitor_name}}  </span>
                    <img v-if="item.visitor_sex == '1'" class="sex-img" src="@/assets/images/男.png" alt="" srcset="">
                    <img v-if="item.visitor_sex == '2'" class="sex-img" src="@/assets/images/女.png" alt="" srcset="">
                  <span>{{item.visitor_age}}</span>
                </div>
                <div class="list-btn-box">
                  <div style="color: #999;">期望就诊时间：{{item.expectedTime}}</div>
                  <!-- <div class="list-btn">抢单:¥{{item.payable_amount.toFixed(2)}}</div> -->
                </div>
              </div>
            </div>
          </div>
          <!-- <div v-else>
            <div @click="toPage('/waiterDetail', {id: item.accompanying_physician_id})" class="list-item-box2" v-for="(item, index) in list" :key="index">
              <div class="list-head-box">
                <img :src="item.head_sculpture" alt="" srcset="">
                <div class="list-name-box">
                  <span class="list-name">{{item.name}}</span>
                  <div class="list-zz">
                    <span v-if="item.isCard != '0'" style="background-color: rgba(89,89,255,.07);color: #1989fa;">{{ active_tab == '2' ? '身份认证' : '陪诊机构'}}</span>
                    <span v-if="item.isQualification != '0'" style="background-color: rgba(234,135,68,.07);color: #ea8744;">{{ active_tab == '2' ? '资格证书' : '机构认证'}}</span>
                  </div>
                  <span class="list-name1">陪诊医院:{{item.hospitalName}}</span>
                  <span class="list-name1">陪诊项目:{{item.giveServiceName}}</span>
                </div>
              </div>
              <div class="list-addr-box">
                <div>
                  <span>陪诊次数：</span>
                  <span class="value-text">{{item.goodsNumbers}}</span>
                  <span>次</span>
                </div>
                <div>
                  <span>陪诊价格：</span>
                  <span class="value-text">{{item.give_service_price}}</span>
                  <span>元起</span>
                </div>
              </div>
            </div>
          </div> -->
        </van-list>
      </div>
    </div>
    <!-- <div class="content-box">
      <div class="module-box">
        <div @click="toServicePage('/productList', {type: item.type}, item.text)" class="item-box" v-for="(item, index) in moduleList" :key="index">
          <img :src="item.img" alt="" srcset="">
          <span>{{item.text}}</span>
        </div>
      </div>
      <div class="module2-box">
        <img @click="toServicePage('/productDetail', {id:'1'}, '一对一陪护')" src="@/assets/images/mk-jypz.png" alt="" srcset="">
        <img @click="toServicePage('/productDetail', {id:'2'}, '院内陪护')" src="@/assets/images/mk-ynph.png" alt="" srcset="">
      </div>
      <div class="module2-box">
        <span>一对一就医陪诊</span>
        <span>院内陪护</span>
      </div>
    </div> -->
  </div>
</template>
<script>
import { Toast } from 'vant'
import { selectGiveServiceCityList, GetDateStr, getZdyDate } from '@/api/medical.js'
import { selectDayList, findAccompanyingOrderList } from '@/api/medicalWaiter.js'
// import yuCalendar from '@/components/yu-calendar/yu-calendar.vue'
import RwCalendar from '@/components/rw-calendar/rw-calendar.vue'
export default {
  name: 'index',
  data () {
    return {
      // active_tab: '1',
      loading: false,
      finished: false,
      list: [],
      moduleList: [
        { id: '1', text: '诊前预约', img: require('@/assets/images/icon-zqyy.png') },
        { id: '1', text: '代办问诊', img: require('@/assets/images/icon-dbwz.png') },
        { id: '1', text: '代办买药', img: require('@/assets/images/icon-dbmy.png') },
        { id: '1', text: '送取结果', img: require('@/assets/images/icon-sqjg.png') },
        { id: '1', text: '就医陪诊', img: require('@/assets/images/icon-jypz.png') }
      ],
      serviceList: [],
      rwDateArr: [],
      flag: false,
      expected_time: '' // 当前日期
    }
  },
  components: { RwCalendar },
  computed: {
    accompanying_physician_id () {
      return this.$store.state.user.severUserInfo.accompanying_physician_id
    }
  },
  created () {},
  methods: {
    toPage (url, params) {
      this.$router.push({
        path: url,
        query: params
      })
    },
    getService () {
      selectGiveServiceCityList({
        province: this.$store.state.app.city.province_code,
        city: this.$store.state.app.city.city_code
      }).then(res => {
        if (res.data.errcode === 0) {
          this.serviceList = res.data.data
        }
      })
    },
    toServicePage (path, query, name) {
      let isGo = false
      this.serviceList.forEach(item => {
        if (item.give_service_name === name) {
          isGo = true
        }
      })
      if (!isGo) {
        Toast.fail('暂无此服务')
        return false
      }
      this.$router.push({
        path,
        query
      })
    },
    getDateTask () {
      selectDayList({ accompanying_physician_id: this.accompanying_physician_id }).then(res => {
        if (res.data.errcode === 0) {
          console.log(res.data.data)
          this.rwDateArr = res.data.data
          for (let i = 0; i < 7; i++) {
            this.rwDateArr[i]['date'] = GetDateStr(i)[0]
            this.rwDateArr[i]['label'] = GetDateStr(i)[2]
            // if (i === 0) {
            //   this.onLoad(this.rwDateArr[i].date)
            // }
          }
          this.expected_time = this.rwDateArr[0].date
          this.flag = true
        }
      })
    },
    onLoad () { // 获取任务订单
      // let apiFun = this.active_tab === '1' ? selectHospitalList : selectAccompanyingPhysicianList
      findAccompanyingOrderList({
        accompanying_physician_id: this.$store.state.user.severUserInfo.accompanying_physician_id,
        province: this.$store.state.app.city.province_code,
        city: this.$store.state.app.city.city_code,
        type: '',
        state: '3',
        expected_time: this.expected_time
      }).then(res => {
        if (res.data.errcode === 0) {
          this.list = res.data.data
          this.loading = false
          this.finished = true
        }
      })
    },
    getCheckDate (date) {
      console.log(date, 'dateeeeeee')
      this.expected_time = date
      this.onLoad()
    }
  },
  mounted () {
    console.log(this.$store.state.user.severUserInfo)
    this.expected_time = getZdyDate(new Date())
    this.getService()
    this.getDateTask()
  }
}
</script>

<style scoped lang="less">
  .content-div{
    background-color: #f8f8f8;
    font-size: 12px;
    min-height: 100%;
    // background-image: url('../../../../assets/images/bg.png');
    // background-repeat: no-repeat;
    // background-size: 100% auto;
    position: relative;
    .banner-box{
      // width: 100%;
      height: auto;
      padding: 0px 10px;
      position: relative;
      .banner-bg{
        width: 120%;
        height: 100%;
        position: absolute;
        z-index: 0;
        left: -10%;
        background-color: #1989fa;
        border-radius: 0 0 50% 50%;
      }
      .banner-head{
        color: #FFFFFF;
        font-size: 12px;
        position: relative;
        z-index: 1;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        box-sizing: border-box;
        padding: 10px;
        .location-box{
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          align-items: center;
          padding-right: 10px;
          img{
            width: 12px;
            height: 12px;
            margin-left: 2px;
          }
        }
        .search-box{
          display: flex;
          flex-direction: row;
          justify-content: flex-start;
          align-items: center;
          padding: 0 10px;
          box-sizing: border-box;
          background-color: #FFFFFF;
          color: #666666;
          border-radius: 17px;
          height: 34px;
          flex: 1;
          span{
            padding-left: 10px;
          }
        }
      }
      .my-swipe{
        width: 300px;
        margin-left: 10px;
        height: 100px;
        border-radius: 6px;
        .van-swipe-item {
          width: 100%;
          img{
            width: 100%;
            height: 100%;
            vertical-align: middle;
          }
        }
      }
    }
    .content-box{
      position: absolute;
      bottom: 80px;
      left: 0;
      .module-box{
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 300px;
        margin-left: 10px;
        padding-top: 10px;
        padding-bottom: 30px;
        .item-box{
          font-size: 12px;
          color: #000000;
          display: flex;
          flex-direction: column;
          align-items: center;
          img{
            width: 38px;
            height: 38px;
            margin-bottom: 6px;
          }
        }
      }
      .module2-box{
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        width: 300px;
        margin-left: 10px;
        padding-bottom: 4px;
        img{
          width: calc((100% - 10px) / 2);
        }
        span{
          width: calc((100% - 10px) / 2);
          text-align: center;
        }
      }
    }
    .list-outbox{
      margin-top: 14px;
      width: 304px;
      margin-left: 8px;
      border-radius: 10px;
      background-color: #FFFFFF;
      margin-bottom: 10px;
      .list-tab-box{
        height: 30px;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        border-radius: 10px 10px 0 0;
        background: linear-gradient(180deg, #B8DBFE, hsla(0,0%,100%,0));
        .tab-item-box{
          min-width: 60px;
          text-align: center;
          height: 100%;
          line-height: 30px;
          font-size: 12px;
        }
        .active-tab{
          background-color: #1989fa;
          border-radius: 10px 0 10px 0;
          color: #FFFFFF;
        }
      }
      .list-search-box{
        padding: 10px;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        font-size: 12px;
        /deep/ .van-dropdown-menu__bar{
          background-color: unset;
          box-shadow: unset;
          height: unset;
        }
        /deep/ .van-dropdown-menu__title{
          padding: 0 10px 0 0;
        }
        /deep/ .van-dropdown-menu{
          margin-right: 20px;
        }
        /deep/ .van-dropdown-menu__title::after{
          right: -.1rem;
        }
      }
      .list-box{
        box-sizing: border-box;
        padding: 10px 8px 8px;
        font-size: 12px;
        .list-item-box1{
          margin-bottom: 10px;
          border-radius: 5px;
          border: 1px solid #eeeeee;
          box-sizing: border-box;
          padding: 11px 7px 10px 8px;
          box-shadow: 0px 0px 10px #eeeeee;
          .list-head-box{
            // display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: flex-start;
            padding-bottom: 6px;
            height: auto;
            .list-name-box{
              // display: flex;
              flex-direction: column;
              justify-content: space-around;
              align-items: flex-start;
              height: 28px;
              border-bottom: 1px solid #edeae6;
              width: 100%;
              .list-name{
                font-weight: bold;
                overflow: hidden;
                text-overflow: ellipsis;
                word-break: break-all;
                white-space: nowrap;
                // width: 100%;
              }
            }
            .list-content-box {
              display: flex;
              height: 18px;
              line-height: 18px;
              padding-top: 7px;
              width: 100%;
            }
            .list-btn-box {
              height: 27px;
              line-height: 27px;
              display: flex;
              flex-direction: row;
              align-items: center;
            }
            // img{
            //   width: 50px;
            //   height: 50px;
            //   margin-right: 10px;
            // }
            .list-btn {
              background: rgba(253, 72, 52, 0.07);
              color: rgb(253, 72, 52);
              border: 1px solid rgba(253, 72, 52, 0.45);
              width: 72px;
              height: 27px;
              border-radius: 5px;
              text-align: center;
              // margin-left: 2px;
              // justify-content: center;
            }
          }
          .list-addr-box{
            color: #1989fa;
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: center;
            span{
              color: #999999;
              padding-left: 4px;
              display: inline-block;
              overflow: hidden;
              text-overflow: ellipsis;
              word-break: break-all;
              white-space: nowrap;
              width: calc(100% - 30px);
            }
          }
        }
        .list-item-box2{
          // background-color: #fff;
          margin-bottom: 10px;
          border-radius: 5px;
          border: 1px solid #eeeeee;
          box-sizing: border-box;
          padding: 10px;
          box-shadow: 0px 0px 10px #eeeeee;
          .list-head-box{
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: flex-start;
            padding-bottom: 6px;
            height: 70px;
            .list-name-box{
              display: flex;
              flex-direction: column;
              justify-content: space-between;
              align-items: flex-start;
              height: 100%;
              width: calc(100% - 80px);
              .list-zz{
                display: flex;
                flex-direction: row;
                justify-content: flex-start;
                align-items: center;
                span{
                  margin-top: 2px;
                  padding: 2px 6px;
                  font-size: 10px;
                  margin-right: 10px;
                  border-radius: 4px;
                }
              }
              .list-name{
                font-weight: bold;
                overflow: hidden;
                text-overflow: ellipsis;
                word-break: break-all;
                white-space: nowrap;
                width: 100%;
              }
              .list-name1{
                color: #AAAAAA;
                overflow: hidden;
                text-overflow: ellipsis;
                word-break: break-all;
                white-space: nowrap;
                width: 100%;
              }
            }
            img{
              width: 70px;
              height: 70px;
              margin-right: 10px;
            }
          }
          .list-addr-box{
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
            color: #999999;
            .value-text{
              color: #1989fa;
            }
          }
        }
      }
    }
    .sex-img {
      width: 18px;
      height: 18px;
      margin-left: 5px;
      margin-right: 2px;
    }
  }
</style>
